package com.smasher.mqtt.interfaces;

import android.content.Context;

import com.smasher.mqtt.config.EasyMqttOptions;
import com.smasher.mqtt.receivers.TopicMessageReceiver;

import org.eclipse.paho.client.mqttv3.MqttMessage;

/**
 * @author HXZ_Android
 */
public interface MqttSubject {

    /**
     * 初始化
     *
     * @param context context
     */
    void createConnection(EasyMqttOptions options, Context context);

    /**
     * 判断是否链接
     *
     * @return boolean
     */
    boolean isConnected();

    /**
     * 订阅
     *
     * @param topic topic
     * @param qos qos
     */
    void subscribe(String topic, int qos);

    /**
     * 取消订阅
     *
     * @param topic topic
     */
    void unsubscribe(String topic);

    /**
     * 发送
     */
    void publish(String topic, String msg, int qos, boolean retained);

    /**
     * 发送
     */
    void publish(String topic, MqttMessage mqttMessage);

    /**
     * 接收器
     */
    void addMessageReceive(TopicMessageReceiver receiver);

    /**
     * 销毁
     */
    void removeMessageReceive(TopicMessageReceiver receiver);

    /**
     * 断开
     */
    void disconnect();

    /**
     * destroy
     */
    void destroy();
}
